<?php echo link_to('жагсаалт', 'banner/index', array('class'=>'title'))?> 
<span class="separator"> | </span>
<?php echo link_to('шинээр нэмэх', 'banner/new', array('class'=>'title'))?>
<br clear="all">
<br clear="all">
<br clear="all">


<form action="<?php echo url_for('banner/index')?>" method="GET">
<fieldset>
<legend>Шүүлт хийх</legend>
  <?php $positions = myConstants::getBannerPositions();?>
  <select name="position" id="position" style="width:400px;">
  <?php foreach ($positions as $key=>$value){
      echo '<option value="'.$key.'" '.(($position == $key) ? 'selected' : '').'>'.$value.'</option>';
  }?>
  </select>
  <input type="submit" value="Харуулах" />
  <br clear="all">
  
  <?php echo link_to('Бүгд', 'banner/index')?> &nbsp; - &nbsp;
  <?php echo link_to('Идэвхитэй', 'banner/index?isActive=1&position='.$position)?> &nbsp; - &nbsp; 
  <?php echo link_to('<span style="background:#ccc;padding:0px 5px;">Идэвхигүй</span>', 'banner/index?isActive=0&position='.$position)?>
</fieldset>
</form>

<?php echo pager($pager, 'banner/index?isActive='.$isActive)?>
<table width="100%">
  <thead>
    <tr>
      <th>Файл</th>
      <th>Линк, шинэ цонхонд нээгдэх</th>
      <th>Хуудас</th>
      <th>Эхлэх хугацаа</th>
      <th>Дуусах хугацаа</th>
      <th>Эрэмбэ</th>
      <th>#</th>
    </tr>
  </thead>
  <tbody>
    <?php foreach ($pager->getResults() as $banner): ?>
    <tr style="background:<?php echo $banner->getIsActive() ? '#fff' : '#ccc'?>">
      <td>
        <b><?php echo $banner->getTitle()?></b><br>
        <?php if($banner->getExt() =='swf'){ ?>
          <object width="200" height="80" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
            <param value="<?php echo '/uploads/banner/'.$banner->getPath()?>" name="movie">
            <param value="high" name="quality">
            <param name="wmode" value="transparent">
            <embed width="200" height="80" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" src="<?php echo '/uploads/banner/'.$banner->getPath()?>" allowscriptaccess="sameDomain" wmode="transparent" />
          </object>
        <?php }else{
        echo image_tag('/uploads/banner/'.$banner->getPath(), array('style'=>'max-width:200px;max-height:150px;'));
        }?>
      </td>
      <td>
        <a href="<?php echo $banner->getLink() ? $banner->getLink() : '#'?>" target="<?php echo $banner->getTarget() ? '_blank' : '_parent'?>">
          <?php echo $banner->getLink();?>
        </a>
        <?php if($banner->getTarget()) echo image_tag('icons/active.png', array('align'=>'absmiddle')) ?></td>
      <td width="20%"><?php echo myConstants::getBannerPositionValue($banner->getPosition()) ?></td>
      <td><?php echo $banner->getStartDate() ?></td>
      <td><?php echo $banner->getEndDate() ?></td>
      <td><?php echo $banner->getSort() ?></td>
      <td>
        <?php if($banner->getIsActive()==1):?>
          <a href="<?php echo url_for('banner/activate?id='.$banner->getId().'&status=0') ?>">Идэвхгүй болгох</a><br>
        <?php else:?>
          <a href="<?php echo url_for('banner/activate?id='.$banner->getId().'&status=1') ?>">Идэвхжүүлэх</a><br>
        <?php endif;?>
          
        <a href="<?php echo url_for('banner/edit?id='.$banner->getId()) ?>">Засварлах</a><br/>
        <a title="Устгах" onclick="return confirm('Та итгэлтэй байна уу?')" href="<?php echo url_for('banner/delete?id='.$banner->getId()) ?>">Устгах</a>
      </td>
    </tr>
    <?php endforeach; ?>
  </tbody>
</table>
<?php echo pager($pager, 'banner/index?isActive='.$isActive)?>